﻿using System;
using System.Collections.Generic;
using System.Data;

namespace RDIFramework.BusinessEntity
{
    using RDIFramework.Utilities;

    /// <summary>
    /// PiTablePermissionScopeEntity
    /// 表数据范围权限
    /// 
    /// 修改纪录
    /// 
    /// 2013-03-08 版本：1.0 EricHu 创建主键。
    /// 
    /// 版本：1.0
    /// 
    /// <author>
    /// <name>EricHu</name>
    /// <date>2013-03-08</date>
    /// </author>
    /// </summary>
    [Serializable]
    public partial class PiTablePermissionScopeEntity
    {
        private int? id = null;
        /// <summary>
        /// 主键
        /// </summary>
        public int? Id
        {
            get
            {
                return this.id;
            }
            set
            {
                this.id = value;
            }
        }

        private int? parentId = null;
        /// <summary>
        /// 表
        /// </summary>
        public int? ParentId
        {
            get
            {
                return this.parentId;
            }
            set
            {
                this.parentId = value;
            }
        }

        private String itemCode = string.Empty;
        /// <summary>
        /// 表名
        /// </summary>
        public String ItemCode
        {
            get
            {
                return this.itemCode;
            }
            set
            {
                this.itemCode = value;
            }
        }

        private String itemName = string.Empty;
        /// <summary>
        /// 表名
        /// </summary>
        public String ItemName
        {
            get
            {
                return this.itemName;
            }
            set
            {
                this.itemName = value;
            }
        }

        private String itemValue = string.Empty;
        /// <summary>
        /// 表
        /// </summary>
        public String ItemValue
        {
            get
            {
                return this.itemValue;
            }
            set
            {
                this.itemValue = value;
            }
        }

        private int? enabled = 1;
        /// <summary>
        /// 有效
        /// </summary>
        public int? Enabled
        {
            get
            {
                return this.enabled;
            }
            set
            {
                this.enabled = value;
            }
        }

        private int? isPublic = 0;
        /// <summary>
        /// 是公开
        /// </summary>
        public int? IsPublic
        {
            get
            {
                return this.isPublic;
            }
            set
            {
                this.isPublic = value;
            }
        }

        private int? allowEdit = 1;
        /// <summary>
        /// 允许编辑
        /// </summary>
        public int? AllowEdit
        {
            get
            {
                return this.allowEdit;
            }
            set
            {
                this.allowEdit = value;
            }
        }

        private int? allowDelete = 1;
        /// <summary>
        /// 允许删除
        /// </summary>
        public int? AllowDelete
        {
            get
            {
                return this.allowDelete;
            }
            set
            {
                this.allowDelete = value;
            }
        }

        private int? deleteMark = 0;
        /// <summary>
        /// 删除标记
        /// </summary>
        public int? DeleteMark
        {
            get
            {
                return this.deleteMark;
            }
            set
            {
                this.deleteMark = value;
            }
        }

        private int? sortCode = null;
        /// <summary>
        /// 排序码
        /// </summary>
        public int? SortCode
        {
            get
            {
                return this.sortCode;
            }
            set
            {
                this.sortCode = value;
            }
        }

        private String description = string.Empty;
        /// <summary>
        /// 描述
        /// </summary>
        public String Description
        {
            get
            {
                return this.description;
            }
            set
            {
                this.description = value;
            }
        }

        private DateTime? createOn = DateTime.Now;
        /// <summary>
        /// 创建日期
        /// </summary>
        public DateTime? CreateOn
        {
            get
            {
                return this.createOn;
            }
            set
            {
                this.createOn = value;
            }
        }

        private String createUserId = string.Empty;
        /// <summary>
        /// 创建用户主键
        /// </summary>
        public String CreateUserId
        {
            get
            {
                return this.createUserId;
            }
            set
            {
                this.createUserId = value;
            }
        }

        private String createBy = string.Empty;
        /// <summary>
        /// 创建用户
        /// </summary>
        public String CreateBy
        {
            get
            {
                return this.createBy;
            }
            set
            {
                this.createBy = value;
            }
        }

        private DateTime? modifiedOn = null;
        /// <summary>
        /// 修改日期
        /// </summary>
        public DateTime? ModifiedOn
        {
            get
            {
                return this.modifiedOn;
            }
            set
            {
                this.modifiedOn = value;
            }
        }

        private String modifyUserId = string.Empty;
        /// <summary>
        /// 修改用户主键
        /// </summary>
        public String ModifyUserId
        {
            get
            {
                return this.modifyUserId;
            }
            set
            {
                this.modifyUserId = value;
            }
        }

        private String modifiedBy = string.Empty;
        /// <summary>
        /// 修改用户
        /// </summary>
        public String ModifiedBy
        {
            get
            {
                return this.modifiedBy;
            }
            set
            {
                this.modifiedBy = value;
            }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public PiTablePermissionScopeEntity()
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataRow">数据行</param>
        public PiTablePermissionScopeEntity(DataRow dataRow)
        {
            this.GetFrom(dataRow);
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataReader">数据流</param>
        public PiTablePermissionScopeEntity(IDataReader dataReader)
        {
            this.GetFrom(dataReader);
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataTable">数据表</param>
        public PiTablePermissionScopeEntity(DataTable dataTable)
        {
            this.GetSingle(dataTable);
        }

        /// <summary>
        /// 从数据表读取
        /// </summary>
        /// <param name="dataTable">数据表</param>
        public PiTablePermissionScopeEntity GetSingle(DataTable dataTable)
        {
            if ((dataTable == null) || (dataTable.Rows.Count == 0))
            {
                return null;
            }
            foreach (DataRow dataRow in dataTable.Rows)
            {
                this.GetFrom(dataRow);
                break;
            }
            return this;
        }

        /// <summary>
        /// 从数据表读取返回实体列表
        /// </summary>
        /// <param name="dataTable">数据表</param>
        public List<PiTablePermissionScopeEntity> GetList(DataTable dataTable)
        {
            List<PiTablePermissionScopeEntity> entities = new List<PiTablePermissionScopeEntity>();
            foreach (DataRow dataRow in dataTable.Rows)
            {
                entities.Add(GetFrom(dataRow));
            }
            return entities;
        }

        /// <summary>
        /// 从数据行读取
        /// </summary>
        /// <param name="dataRow">数据行</param>
        public PiTablePermissionScopeEntity GetFrom(DataRow dataRow)
        {
            this.Id = BusinessLogic.ConvertToInt(dataRow[PiTablePermissionScopeTable.FieldId]);
            this.ParentId = BusinessLogic.ConvertToInt(dataRow[PiTablePermissionScopeTable.FieldParentId]);
            this.ItemCode = BusinessLogic.ConvertToString(dataRow[PiTablePermissionScopeTable.FieldItemCode]);
            this.ItemName = BusinessLogic.ConvertToString(dataRow[PiTablePermissionScopeTable.FieldItemName]);
            this.ItemValue = BusinessLogic.ConvertToString(dataRow[PiTablePermissionScopeTable.FieldItemValue]);
            this.Enabled = BusinessLogic.ConvertToInt(dataRow[PiTablePermissionScopeTable.FieldEnabled]);
            this.IsPublic = BusinessLogic.ConvertToInt(dataRow[PiTablePermissionScopeTable.FieldIsPublic]);
            this.AllowEdit = BusinessLogic.ConvertToInt(dataRow[PiTablePermissionScopeTable.FieldAllowEdit]);
            this.AllowDelete = BusinessLogic.ConvertToInt(dataRow[PiTablePermissionScopeTable.FieldAllowDelete]);
            this.DeleteMark = BusinessLogic.ConvertToInt(dataRow[PiTablePermissionScopeTable.FieldDeleteMark]);
            this.SortCode = BusinessLogic.ConvertToInt(dataRow[PiTablePermissionScopeTable.FieldSortCode]);
            this.Description = BusinessLogic.ConvertToString(dataRow[PiTablePermissionScopeTable.FieldDescription]);
            this.CreateOn = BusinessLogic.ConvertToDateTime(dataRow[PiTablePermissionScopeTable.FieldCreateOn]);
            this.CreateUserId = BusinessLogic.ConvertToString(dataRow[PiTablePermissionScopeTable.FieldCreateUserId]);
            this.CreateBy = BusinessLogic.ConvertToString(dataRow[PiTablePermissionScopeTable.FieldCreateBy]);
            this.ModifiedOn = BusinessLogic.ConvertToDateTime(dataRow[PiTablePermissionScopeTable.FieldModifiedOn]);
            this.ModifyUserId = BusinessLogic.ConvertToString(dataRow[PiTablePermissionScopeTable.FieldModifyUserId]);
            this.ModifiedBy = BusinessLogic.ConvertToString(dataRow[PiTablePermissionScopeTable.FieldModifiedBy]);
            return this;
        }

        /// <summary>
        /// 从数据流读取
        /// </summary>
        /// <param name="dataReader">数据流</param>
        public PiTablePermissionScopeEntity GetFrom(IDataReader dataReader)
        {
            this.Id = BusinessLogic.ConvertToInt(dataReader[PiTablePermissionScopeTable.FieldId]);
            this.ParentId = BusinessLogic.ConvertToInt(dataReader[PiTablePermissionScopeTable.FieldParentId]);
            this.ItemCode = BusinessLogic.ConvertToString(dataReader[PiTablePermissionScopeTable.FieldItemCode]);
            this.ItemName = BusinessLogic.ConvertToString(dataReader[PiTablePermissionScopeTable.FieldItemName]);
            this.ItemValue = BusinessLogic.ConvertToString(dataReader[PiTablePermissionScopeTable.FieldItemValue]);
            this.Enabled = BusinessLogic.ConvertToInt(dataReader[PiTablePermissionScopeTable.FieldEnabled]);
            this.IsPublic = BusinessLogic.ConvertToInt(dataReader[PiTablePermissionScopeTable.FieldIsPublic]);
            this.AllowEdit = BusinessLogic.ConvertToInt(dataReader[PiTablePermissionScopeTable.FieldAllowEdit]);
            this.AllowDelete = BusinessLogic.ConvertToInt(dataReader[PiTablePermissionScopeTable.FieldAllowDelete]);
            this.DeleteMark = BusinessLogic.ConvertToInt(dataReader[PiTablePermissionScopeTable.FieldDeleteMark]);
            this.SortCode = BusinessLogic.ConvertToInt(dataReader[PiTablePermissionScopeTable.FieldSortCode]);
            this.Description = BusinessLogic.ConvertToString(dataReader[PiTablePermissionScopeTable.FieldDescription]);
            this.CreateOn = BusinessLogic.ConvertToDateTime(dataReader[PiTablePermissionScopeTable.FieldCreateOn]);
            this.CreateUserId = BusinessLogic.ConvertToString(dataReader[PiTablePermissionScopeTable.FieldCreateUserId]);
            this.CreateBy = BusinessLogic.ConvertToString(dataReader[PiTablePermissionScopeTable.FieldCreateBy]);
            this.ModifiedOn = BusinessLogic.ConvertToDateTime(dataReader[PiTablePermissionScopeTable.FieldModifiedOn]);
            this.ModifyUserId = BusinessLogic.ConvertToString(dataReader[PiTablePermissionScopeTable.FieldModifyUserId]);
            this.ModifiedBy = BusinessLogic.ConvertToString(dataReader[PiTablePermissionScopeTable.FieldModifiedBy]);
            return this;
        }
    }
}
